// SEE END OF FILE FOR LICENSE TERMS

#include "dualStepMixer_defines.h"

#ifndef MIXER_H
#define MIXER_H

// A lookup table of input channel trims used to apply to outputs 
const unsigned char outputTrimChannels[MAX_OUTPUTS+1] =
	{
		CHANNEL_UNUSED	,
		AILERON_INPUT_CHANNEL	,
		ELEVATOR_INPUT_CHANNEL	,
		THROTTLE_INPUT_CHANNEL	,
		RUDDER_INPUT_CHANNEL	,
		AILERON2_INPUT_CHANNEL	,
		FLAP_INPUT_CHANNEL	,
		FLAP2_INPUT_CHANNEL	,
		MODE_SWITCH_INPUT_CHANNEL	,
	};


// Mixer settings
const MIXER_SETTINGS controlMixers[] = 
		{
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AP_ROLL_CONTROL	,	CONTROL_ROLL	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AP_PITCH_CONTROL	,	CONTROL_PITCH	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AP_YAW_CONTROL	,	CONTROL_YAW	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AP_THROTTLE_CONTROL	,	CONTROL_THROTTLE	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AP_CAMBER_CONTROL	,	CONTROL_CAMBER	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AP_FLAP_CONTROL	,	CONTROL_FLAP	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AP_SPOILER_CONTROL	,	CONTROL_SPOILER	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	10	) , percenttoQ14(	0	),	AP_PITCH_CONTROL	,	CONTROL_CAMBER	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	50	) , percenttoQ14(	50	),	AP_FLAP_CONTROL	,	CONTROL_SPOILER	,	MIX_SRC_AP	,	8	}	,
			{ percenttoQ14(	20	) , percenttoQ14(	20	),	AP_ROLL_CONTROL	,	CONTROL_YAW	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	0	) , percenttoQ14(	20	),	AP_FLAP_CONTROL	,	CONTROL_PITCH	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	0	) , percenttoQ14(	0	),	AILERON_INPUT_CHANNEL	,	CONTROL_YAW	,	MIX_SRC_RADIO	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AP_WAGGLE_CONTROL	,	CONTROL_ROLL	,	MIX_SRC_AP	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AP_WAGGLE_CONTROL	,	CONTROL_PITCH	,	MIX_SRC_AP	,	1	}	,

		};


const MIXER_SETTINGS surfaceMixers[] = 
		{
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AILERON_INPUT_CHANNEL	,	AILERON_OUTPUT_CHANNEL	,	MIX_SRC_RADIO	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	ELEVATOR_INPUT_CHANNEL	,	ELEVATOR_OUTPUT_CHANNEL	,	MIX_SRC_RADIO	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	THROTTLE_INPUT_CHANNEL	,	THROTTLE_OUTPUT_CHANNEL	,	MIX_SRC_RADIO	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	RUDDER_INPUT_CHANNEL	,	RUDDER_OUTPUT_CHANNEL	,	MIX_SRC_RADIO	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	AILERON2_INPUT_CHANNEL	,	AILERON2_OUTPUT_CHANNEL	,	MIX_SRC_RADIO	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	FLAP_INPUT_CHANNEL	,	FLAP_OUTPUT_CHANNEL	,	MIX_SRC_RADIO	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	FLAP2_INPUT_CHANNEL	,	FLAP2_OUTPUT_CHANNEL	,	MIX_SRC_RADIO	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	MODE_SWITCH_INPUT_CHANNEL	,	MODE_OUTPUT_CHANNEL	,	MIX_SRC_RADIO	,	0	}	,
			
			{ percenttoQ14(	100	) , percenttoQ14(	50	),	CONTROL_ROLL	,	AILERON_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	-50	) , percenttoQ14(	100	),	CONTROL_ROLL	,	AILERON2_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	CONTROL_PITCH	,	ELEVATOR_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	CONTROL_YAW	,	RUDDER_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	CONTROL_THROTTLE	,	CONTROL_THROTTLE	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	10	) , percenttoQ14(	5	),	CONTROL_CAMBER	,	AILERON_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	10	) , percenttoQ14(	5	),	CONTROL_CAMBER	,	AILERON2_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	10	) , percenttoQ14(	5	),	CONTROL_CAMBER	,	FLAP_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	10	) , percenttoQ14(	5	),	CONTROL_CAMBER	,	FLAP2_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	CONTROL_FLAP	,	FLAP_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	100	) , percenttoQ14(	100	),	CONTROL_FLAP	,	FLAP2_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	-30	) , percenttoQ14(	-30	),	CONTROL_FLAP	,	AILERON_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	-30	) , percenttoQ14(	-30	),	CONTROL_FLAP	,	AILERON2_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	-50	) , percenttoQ14(	-50	),	CONTROL_SPOILER	,	AILERON_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,
			{ percenttoQ14(	-50	) , percenttoQ14(	-50	),	CONTROL_SPOILER	,	AILERON2_OUTPUT_CHANNEL	,	MIX_SRC_CONTROLS	,	0	}	,

		};

#endif

/****************************************************************************/
// This is part of the servo and radio interface software
//
// ServoInterface source code
//	http://code.google.com/p/rc-servo-interface
//
// Copyright 2010 ServoInterface Team
// See the AUTHORS.TXT file for a list of authors of ServoInterface.
//
// ServoInterface is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ServoInterface is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License 
// along with ServoInterface.  If not, see <http://www.gnu.org/licenses/>.
//
// Many parts of ServoInterface use either modified or unmodified code
// from the MatrixPilot pilot project.
// The project also contains code for modifying MatrixPilot to operate
// with ServoInterface.
// For details, credits and licenses of MatrixPilot see the AUTHORS.TXT file.
// or see this website: http://code.google.com/p/gentlenav
/****************************************************************************/
